<?php
require_once(ROOTDIR."/include/database/class.LengthQueries.php");

$lengthQueries = new LengthQueries();
$banLengths = $lengthQueries->getLengthList();

echo "\"GlobalBan_Length\"\n";
echo "{\n";

// Cycle through each user and create the keygroup
foreach($banLengths as $banLength) {

  $readable = $banLength->getLength() . " " . $banLength->getTimeScale();

  if($banLength->getLength() == 0) {
    $readable = "Forever";
  } else if($banLength->getLength() == 1) {
    if($banLength->getTimeScale() == "minutes") {
      $readable = $banLength->getLength() . " minute";
    } else if($banLength->getTimeScale() == "hours") {
      $readable = $banLength->getLength() . " hour";
    } else if($banLength->getTimeScale() == "days") {
      $readable = $banLength->getLength() . " day";
    } else if($banLength->getTimeScale() == "weeks") {
      $readable = $banLength->getLength() . " week";
    } else if($banLength->getTimeScale() == "months") {
      $readable = $banLength->getLength() . " month";
    }
  }

  echo "  \"".$banLength->getId()."\"\n";
  echo "  {\n";
  echo "    \"length\"        \"".$banLength->getLength()."\"\n";
  echo "    \"timeScale\"     \"".$banLength->getTimeScale()."\"\n";
  echo "    \"readable\"      \"".$readable."\"\n";
  echo "  }\n";
}
?>
}